﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HousingDistribution
{
    public partial class FormFormerHouse : Form
    {
        public FormFormerHouse()
        {
            InitializeComponent();

            DGVInit.Init(ref this.dataGridViewFormerHouse, DataDictionary.Instance().GetDGVConf(DataDictionary.Instance().dgvNames[4]));
        }

        public void HisrotyHouse(List<int> formerHousingId)
        {
            if (formerHousingId.Count == 0)
                return;

            StringBuilder sql = new StringBuilder("select * from housing where ");
               
            for (int i=0; i<formerHousingId.Count ;i++)
            {
                sql.Append("idhousing ='");
                sql.Append(formerHousingId[i]);
                sql.Append("' or ");
            }

            //取出最后的 " or "
            sql.Remove(sql.Length - 4, 4);

            DataTable dt = DBProc.Instance().ReadData(sql.ToString()).Tables[0];
            dataGridViewFormerHouse.DataSource = dt;
        }

        private void buttonExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
